package mutils

import (
	"math/rand"
	"time"
)


func OnlyRand(max int, array []int)(result int)  {
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	num := r.Intn(max)
	if isArrayHas(array, num) {
		return OnlyRand(max, array)
	}else {
		return num
	}
}

func isArrayHas(array []int,str int) (result bool) {
	for i := range array {
		if i == str {
			return true
		}
	}
	return false
}

func NowTime() (now string)  {
	t := time.Now().Unix()
	tm := time.Unix(t, 0)
	timestr := tm.Format("2006-01-02 03:04:05 PM")
	return timestr
}